package web_middleware

import (
	"gfrest/common/ctxkit"
	"gfrest/common/log"

	"github.com/gogf/gf/net/ghttp"
	"github.com/rs/xid"
)

// ReqIDMiddleware 中间件
func ReqIDMiddleware(r *ghttp.Request) {

	guid := xid.New().String()

	r = ctxkit.WithReqID(r, guid)
	r = ctxkit.WithUserIP(r, r.RemoteAddr)
	r = ctxkit.WithReqStartTime(r)
	r = log.WithCtxLogger(r)
	r.Middleware.Next()
	log.Infof(r.Context(), "url: %v, data: %v", r.Request.URL, r.GetMap())

}
